import static org.junit.Assert.assertEquals;
import game.Game;
import game.GameDriver;
import game.Round;

import java.awt.Color;

import org.junit.Before;
import org.junit.Test;

import player.Alien;
import player.Flapper;
import player.Human;
import player.Player;
import town.Store;

public class BradleyTest {
    GameDriver driver;
    Game game;
    Round round;

    Player p1;
    Player p2;
    Player p3;
    Player p4;

    Store store;

    @Before
    public void setUp() {
	this.driver = new GameDriver();
    }

    @Test
    public void testBeginnerGame() {
	// beginner game with 4 Players
	game = new Game(4, 1, 1);

	p1 = new Player(game, "bob", Color.RED, "red", new Flapper());
	p2 = new Player(game, "sally", Color.CYAN, "cyan", new Human());
	p3 = new Player(game, "dave", Color.GREEN, "green", new Human());
	p4 = new Player(game, "phil", Color.YELLOW, "yellow", new Alien());

	game.setPlayer(p1, 0);
	game.setPlayer(p2, 1);
	game.setPlayer(p3, 2);
	game.setPlayer(p4, 3);

	round = new Round(game, driver);
	store = new Store(game, driver, round);

	assertEquals(p1.getResourceBasket().getResource(0), 8);
	assertEquals(p1.getResourceBasket().getResource(1), 4);
	assertEquals(p1.getResourceBasket().getResource(4), 1600);

	assertEquals(p2.getResourceBasket().getResource(0), 8);
	assertEquals(p2.getResourceBasket().getResource(1), 4);
	assertEquals(p2.getResourceBasket().getResource(4), 600);

	assertEquals(p3.getResourceBasket().getResource(0), 8);
	assertEquals(p3.getResourceBasket().getResource(1), 4);
	assertEquals(p3.getResourceBasket().getResource(4), 600);

	assertEquals(p4.getResourceBasket().getResource(0), 8);
	assertEquals(p4.getResourceBasket().getResource(1), 4);
	assertEquals(p4.getResourceBasket().getResource(4), 1000);

	assertEquals(store.getResourceBasket().getResource(0), 16);
	assertEquals(store.getResourceBasket().getResource(1), 16);
	assertEquals(store.getResourceBasket().getResource(5), 25);

    }

    @Test
    public void testStandardGame() {
	// beginner game with 4 Players
	game = new Game(4, 2, 1);

	p1 = new Player(game, "bob", Color.RED, "red", new Flapper());
	p2 = new Player(game, "sally", Color.CYAN, "cyan", new Human());
	p3 = new Player(game, "dave", Color.GREEN, "green", new Human());
	p4 = new Player(game, "phil", Color.YELLOW, "yellow", new Alien());

	game.setPlayer(p1, 0);
	game.setPlayer(p2, 1);
	game.setPlayer(p3, 2);
	game.setPlayer(p4, 3);

	round = new Round(game, driver);
	store = new Store(game, driver, round);

	assertEquals(p1.getResourceBasket().getResource(0), 4);
	assertEquals(p1.getResourceBasket().getResource(1), 2);
	assertEquals(p1.getResourceBasket().getResource(4), 1600);

	assertEquals(p2.getResourceBasket().getResource(0), 4);
	assertEquals(p2.getResourceBasket().getResource(1), 2);
	assertEquals(p2.getResourceBasket().getResource(4), 600);

	assertEquals(p3.getResourceBasket().getResource(0), 4);
	assertEquals(p3.getResourceBasket().getResource(1), 2);
	assertEquals(p3.getResourceBasket().getResource(4), 600);

	assertEquals(p4.getResourceBasket().getResource(0), 4);
	assertEquals(p4.getResourceBasket().getResource(1), 2);
	assertEquals(p4.getResourceBasket().getResource(4), 1000);

	assertEquals(store.getResourceBasket().getResource(0), 8);
	assertEquals(store.getResourceBasket().getResource(1), 8);
	assertEquals(store.getResourceBasket().getResource(2), 8);
	assertEquals(store.getResourceBasket().getResource(5), 14);
    }
}
